//
//  ViewController.m
//  自定义KVO
//
//  Created by 崔博 on 2017/12/25.
//  Copyright © 2017年 崔博. All rights reserved.
//

#import "ViewController.h"
#import "Person.h"
#import "NSObject+BBKvo.h"
@interface ViewController ()
@property (nonatomic, strong) Person * p;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    Person * per = [[Person alloc] init];
    _p = per;
    [per bb_addObserver:self forKeyPath:@"name" options:0 context:nil];
    NSLog(@"%@",[per class]);
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context{
    NSLog(@"我来了");
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    static int i = 0;
    i++;
    _p.name = [NSString stringWithFormat:@"%d",i];
}
@end
